<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Time::Piece - Object Oriented time objects - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Time::Piece">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Time::Piece.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Time::Piece">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Time::Piece">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Time::Piece">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Time::Piece">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Time::Piece">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Time::Piece">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Time::Piece">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Time::Piece">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Time::Piece">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Time::Piece">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Time::Piece">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Time::Piece">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Time::Piece">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Time::Piece">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Time::Piece">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Time::Piece">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Time::Piece">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Time::Piece">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Time::Piece">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Time::Piece">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Time::Piece">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Time::Piece">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Time::Piece">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Time::Piece">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Time::Piece">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Time::Piece">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Time::Piece">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Time::Piece">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Time::Piece">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Time::Piece">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Time::Piece">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Time::Piece">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Time::Piece">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Time::Piece">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Time::Piece">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Time::Piece">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Time::Piece">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Time::Piece">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Time::Piece">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Time::Piece">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Time::Piece">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Time::Piece">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Time::Piece">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Time::Piece">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Time::Piece">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Time::Piece">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Time::Piece">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Time::Piece">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Time::Piece">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Time::Piece">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Time::Piece">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Time::Piece">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Time::Piece">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Time::Piece">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Time::Piece">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Time::Piece">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Time::Piece">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Time::Piece">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Time::Piece">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Time::Piece">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Time::Piece">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Time::Piece">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Time::Piece">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Time::Piece">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Time::Piece">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Time::Piece">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Time::Piece">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Time::Piece">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Time::Piece">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Time::Piece">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Time::Piece">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Time::Piece">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Time::Piece">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Time::Piece">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Time::Piece">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Time::Piece">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Time::Piece">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Time::Piece">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Time::Piece">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Time::Piece">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Time::Piece.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Time::Piece">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Time::Piece">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Time::Piece">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Time::Piece">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Time::Piece">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Time::Piece">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Time::Piece">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Time::Piece">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Time::Piece">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Time::Piece">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Time::Piece">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Time::Piece">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Time::Piece">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Time::Piece">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Time::Piece">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Time::Piece">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Time::Piece">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Time::Piece">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Time::Piece">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Time::Piece">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Time::Piece">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Time::Piece">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Time::Piece">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Time::Piece">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Time::Piece">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Time::Piece">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Time::Piece">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Time::Piece">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Time::Piece">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Time::Piece">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Time::Piece">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Time::Piece">5.35.1</a>
          <a class="dropdown-item active" href="./Time::Piece.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Time::Piece.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Time::Piece.html">Time::Piece</a>
          <div id="more">
            (<a href="./Time::Piece.txt">source</a>,
            <a href="https://metacpan.org/pod/Time::Piece">CPAN</a>)
          </div>
            <div id="moduleversion">version 1.3401</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#USAGE">USAGE</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Local-Locales">Local Locales</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Date-Calculations">Date Calculations</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Truncation">Truncation</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Date-Comparisons">Date Comparisons</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Date-Parsing">Date Parsing</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#CAVEAT-%25A,-%25a,-%25B,-%25b,-and-friends">CAVEAT %A, %a, %B, %b, and friends</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#YYYY-MM-DDThh:mm:ss">YYYY-MM-DDThh:mm:ss</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Week-Number">Week Number</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Global-Overriding">Global Overriding</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#CAVEATS">CAVEATS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Setting-$ENV%7BTZ%7D-in-Threads-on-Win32">Setting $ENV{TZ} in Threads on Win32</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#Use-of-epoch-seconds">Use of epoch seconds</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#AUTHOR">AUTHOR</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#COPYRIGHT-AND-LICENSE">COPYRIGHT AND LICENSE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#SEE-ALSO">SEE ALSO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Time::Piece.html#BUGS">BUGS</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Time::Piece.html#NAME">#</a>NAME</h1>

<p>Time::Piece - Object Oriented time objects</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Time::Piece.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code>use Time::Piece;

my $t = localtime;
print &quot;Time is $t\n&quot;;
print &quot;Year is &quot;, $t-&gt;year, &quot;\n&quot;;</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="./Time::Piece.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>This module replaces the standard <code>localtime</code> and <code>gmtime</code> functions with implementations that return objects. It does so in a backwards compatible manner, so that using localtime/gmtime in the way documented in perlfunc will still return what you expect.</p>

<p>The module actually implements most of an interface described by Larry Wall on the perl5-porters mailing list here: <a href="https://www.nntp.perl.org/group/perl.perl5.porters/2000/01/msg5283.html">https://www.nntp.perl.org/group/perl.perl5.porters/2000/01/msg5283.html</a></p>

<h1 id="USAGE"><a class="permalink" href="./Time::Piece.html#USAGE">#</a>USAGE</h1>

<p>After importing this module, when you use localtime or gmtime in a scalar context, rather than getting an ordinary scalar string representing the date and time, you get a Time::Piece object, whose stringification happens to produce the same effect as the localtime and gmtime functions. There is also a new() constructor provided, which is the same as localtime(), except when passed a Time::Piece object, in which case it&#39;s a copy constructor. The following methods are available on the object:</p>

<pre><code>$t-&gt;sec                 # also available as $t-&gt;second
$t-&gt;min                 # also available as $t-&gt;minute
$t-&gt;hour                # 24 hour
$t-&gt;mday                # also available as $t-&gt;day_of_month
$t-&gt;mon                 # 1 = January
$t-&gt;_mon                # 0 = January
$t-&gt;monname             # Feb
$t-&gt;month               # same as $t-&gt;monname
$t-&gt;fullmonth           # February
$t-&gt;year                # based at 0 (year 0 AD is, of course 1 BC)
$t-&gt;_year               # year minus 1900
$t-&gt;yy                  # 2 digit year
$t-&gt;wday                # 1 = Sunday
$t-&gt;_wday               # 0 = Sunday
$t-&gt;day_of_week         # 0 = Sunday
$t-&gt;wdayname            # Tue
$t-&gt;day                 # same as wdayname
$t-&gt;fullday             # Tuesday
$t-&gt;yday                # also available as $t-&gt;day_of_year, 0 = Jan 01
$t-&gt;isdst               # also available as $t-&gt;daylight_savings

$t-&gt;hms                 # 12:34:56
$t-&gt;hms(&quot;.&quot;)            # 12.34.56
$t-&gt;time                # same as $t-&gt;hms

$t-&gt;ymd                 # 2000-02-29
$t-&gt;date                # same as $t-&gt;ymd
$t-&gt;mdy                 # 02-29-2000
$t-&gt;mdy(&quot;/&quot;)            # 02/29/2000
$t-&gt;dmy                 # 29-02-2000
$t-&gt;dmy(&quot;.&quot;)            # 29.02.2000
$t-&gt;datetime            # 2000-02-29T12:34:56 (ISO 8601)
$t-&gt;cdate               # Tue Feb 29 12:34:56 2000
&quot;$t&quot;                    # same as $t-&gt;cdate

$t-&gt;epoch               # seconds since the epoch
$t-&gt;tzoffset            # timezone offset in a Time::Seconds object

$t-&gt;julian_day          # number of days since Julian period began
$t-&gt;mjd                 # modified Julian date (JD-2400000.5 days)

$t-&gt;week                # week number (ISO 8601)

$t-&gt;is_leap_year        # true if it&#39;s a leap year
$t-&gt;month_last_day      # 28-31

$t-&gt;time_separator($s)  # set the default separator (default &quot;:&quot;)
$t-&gt;date_separator($s)  # set the default separator (default &quot;-&quot;)
$t-&gt;day_list(@days)     # set the default weekdays
$t-&gt;mon_list(@days)     # set the default months

$t-&gt;strftime(FORMAT)    # same as POSIX::strftime (without the overhead
                        # of the full POSIX extension)
$t-&gt;strftime()          # &quot;Tue, 29 Feb 2000 12:34:56 GMT&quot;

Time::Piece-&gt;strptime(STRING, FORMAT)
                        # see strptime man page. Creates a new
                        # Time::Piece object</code></pre>

<p>Note that <code>localtime</code> and <code>gmtime</code> are not listed above. If called as methods on a Time::Piece object, they act as constructors, returning a new Time::Piece object for the current time. In other words: they&#39;re not useful as methods.</p>

<h2 id="Local-Locales"><a class="permalink" href="./Time::Piece.html#Local-Locales">#</a><a id="Local"></a>Local Locales</h2>

<p>Both wdayname (day) and monname (month) allow passing in a list to use to index the name of the days against. This can be useful if you need to implement some form of localisation without actually installing or using locales. Note that this is a global override and will affect all Time::Piece instances.</p>

<pre><code>my @days = qw( Dimanche Lundi Merdi Mercredi Jeudi Vendredi Samedi );

my $french_day = localtime-&gt;day(@days);</code></pre>

<p>These settings can be overridden globally too:</p>

<pre><code>Time::Piece::day_list(@days);</code></pre>

<p>Or for months:</p>

<pre><code>Time::Piece::mon_list(@months);</code></pre>

<p>And locally for months:</p>

<pre><code>print localtime-&gt;month(@months);</code></pre>

<p>Or to populate with your current system locale call: Time::Piece-&gt;use_locale();</p>

<h2 id="Date-Calculations"><a class="permalink" href="./Time::Piece.html#Date-Calculations">#</a><a id="Date"></a>Date Calculations</h2>

<p>It&#39;s possible to use simple addition and subtraction of objects:</p>

<pre><code>use Time::Seconds;

my $seconds = $t1 - $t2;
$t1 += ONE_DAY; # add 1 day (constant from Time::Seconds)</code></pre>

<p>The following are valid ($t1 and $t2 are Time::Piece objects):</p>

<pre><code>$t1 - $t2; # returns Time::Seconds object
$t1 - 42; # returns Time::Piece object
$t1 + 533; # returns Time::Piece object</code></pre>

<p>However adding a Time::Piece object to another Time::Piece object will cause a runtime error.</p>

<p>Note that the first of the above returns a Time::Seconds object, so while examining the object will print the number of seconds (because of the overloading), you can also get the number of minutes, hours, days, weeks and years in that delta, using the Time::Seconds API.</p>

<p>In addition to adding seconds, there are two APIs for adding months and years:</p>

<pre><code>$t = $t-&gt;add_months(6);
$t = $t-&gt;add_years(5);</code></pre>

<p>The months and years can be negative for subtractions. Note that there is some &quot;strange&quot; behaviour when adding and subtracting months at the ends of months. Generally when the resulting month is shorter than the starting month then the number of overlap days is added. For example subtracting a month from 2008-03-31 will not result in 2008-02-31 as this is an impossible date. Instead you will get 2008-03-02. This appears to be consistent with other date manipulation tools.</p>

<h2 id="Truncation"><a class="permalink" href="./Time::Piece.html#Truncation">#</a>Truncation</h2>

<p>Calling the <code>truncate</code> method returns a copy of the object but with the time truncated to the start of the supplied unit.</p>

<pre><code>$t = $t-&gt;truncate(to =&gt; &#39;day&#39;);</code></pre>

<p>This example will set the time to midnight on the same date which <code>$t</code> had previously. Allowed values for the &quot;to&quot; parameter are: &quot;year&quot;, &quot;quarter&quot;, &quot;month&quot;, &quot;day&quot;, &quot;hour&quot;, &quot;minute&quot; and &quot;second&quot;.</p>

<h2 id="Date-Comparisons"><a class="permalink" href="./Time::Piece.html#Date-Comparisons">#</a><a id="Date1"></a>Date Comparisons</h2>

<p>Date comparisons are also possible, using the full suite of &quot;&lt;&quot;, &quot;&gt;&quot;, &quot;&lt;=&quot;, &quot;&gt;=&quot;, &quot;&lt;=&gt;&quot;, &quot;==&quot; and &quot;!=&quot;.</p>

<h2 id="Date-Parsing"><a class="permalink" href="./Time::Piece.html#Date-Parsing">#</a><a id="Date2"></a>Date Parsing</h2>

<p>Time::Piece has a built-in strptime() function (from FreeBSD), allowing you incredibly flexible date parsing routines. For example:</p>

<pre><code>my $t = Time::Piece-&gt;strptime(&quot;Sunday 3rd Nov, 1943&quot;,
                              &quot;%A %drd %b, %Y&quot;);

print $t-&gt;strftime(&quot;%a, %d %b %Y&quot;);</code></pre>

<p>Outputs:</p>

<pre><code class="plaintext">Wed, 03 Nov 1943</code></pre>

<p>(see, it&#39;s even smart enough to fix my obvious date bug)</p>

<p>For more information see &quot;man strptime&quot;, which should be on all unix systems.</p>

<p>Alternatively look here: <a href="http://www.unix.com/man-page/FreeBSD/3/strftime/">http://www.unix.com/man-page/FreeBSD/3/strftime/</a></p>

<h3 id="CAVEAT-%A,-%a,-%B,-%b,-and-friends"><a class="permalink" href="./Time::Piece.html#CAVEAT-%25A,-%25a,-%25B,-%25b,-and-friends">#</a><a id="CAVEAT"></a><a id="CAVEAT-A-a-B-b-and-friends"></a>CAVEAT %A, %a, %B, %b, and friends</h3>

<p>Time::Piece::strptime by default can only parse American English date names. Meanwhile, Time::Piece-&gt;strftime() will return date names that use the current configured system locale. This means dates returned by strftime might not be able to be parsed by strptime. This is the default behavior and can be overridden by calling Time::Piece-&gt;use_locale(). This builds a list of the current locale&#39;s day and month names which strptime will use to parse with. Note this is a global override and will affect all Time::Piece instances.</p>

<p>For instance with a German locale:</p>

<pre><code>localtime-&gt;day_list();</code></pre>

<p>Returns</p>

<pre><code class="plaintext">( &#39;Sun&#39;, &#39;Mon&#39;, &#39;Tue&#39;, &#39;Wed&#39;, &#39;Thu&#39;, &#39;Fri&#39;, &#39;Sat&#39; )</code></pre>

<p>While:</p>

<pre><code>Time::Piece-&gt;use_locale();
localtime-&gt;day_list();</code></pre>

<p>Returns</p>

<pre><code class="plaintext">( &#39;So&#39;, &#39;Mo&#39;, &#39;Di&#39;, &#39;Mi&#39;, &#39;Do&#39;, &#39;Fr&#39;, &#39;Sa&#39; )</code></pre>

<h2 id="YYYY-MM-DDThh:mm:ss"><a class="permalink" href="./Time::Piece.html#YYYY-MM-DDThh:mm:ss">#</a><a id="YYYY"></a>YYYY-MM-DDThh:mm:ss</h2>

<p>The ISO 8601 standard defines the date format to be YYYY-MM-DD, and the time format to be hh:mm:ss (24 hour clock), and if combined, they should be concatenated with date first and with a capital &#39;T&#39; in front of the time.</p>

<h2 id="Week-Number"><a class="permalink" href="./Time::Piece.html#Week-Number">#</a><a id="Week"></a>Week Number</h2>

<p>The <i>week number</i> may be an unknown concept to some readers. The ISO 8601 standard defines that weeks begin on a Monday and week 1 of the year is the week that includes both January 4th and the first Thursday of the year. In other words, if the first Monday of January is the 2nd, 3rd, or 4th, the preceding days of the January are part of the last week of the preceding year. Week numbers range from 1 to 53.</p>

<h2 id="Global-Overriding"><a class="permalink" href="./Time::Piece.html#Global-Overriding">#</a><a id="Global"></a>Global Overriding</h2>

<p>Finally, it&#39;s possible to override localtime and gmtime everywhere, by including the &#39;:override&#39; tag in the import list:</p>

<pre><code>use Time::Piece &#39;:override&#39;;</code></pre>

<h1 id="CAVEATS"><a class="permalink" href="./Time::Piece.html#CAVEATS">#</a>CAVEATS</h1>

<h2 id="Setting-$ENV{TZ}-in-Threads-on-Win32"><a class="permalink" href="./Time::Piece.html#Setting-$ENV%7BTZ%7D-in-Threads-on-Win32">#</a><a id="Setting"></a><a id="Setting-ENV-TZ-in-Threads-on-Win32"></a>Setting $ENV{TZ} in Threads on Win32</h2>

<p>Note that when using perl in the default build configuration on Win32 (specifically, when perl is built with PERL_IMPLICIT_SYS), each perl interpreter maintains its own copy of the environment and only the main interpreter will update the process environment seen by strftime.</p>

<p>Therefore, if you make changes to $ENV{TZ} from inside a thread other than the main thread then those changes will not be seen by strftime if you subsequently call that with the %Z formatting code. You must change $ENV{TZ} in the main thread to have the desired effect in this case (and you must also call _tzset() in the main thread to register the environment change).</p>

<p>Furthermore, remember that this caveat also applies to fork(), which is emulated by threads on Win32.</p>

<h2 id="Use-of-epoch-seconds"><a class="permalink" href="./Time::Piece.html#Use-of-epoch-seconds">#</a><a id="Use"></a>Use of epoch seconds</h2>

<p>This module internally uses the epoch seconds system that is provided via the perl <code>time()</code> function and supported by <code>gmtime()</code> and <code>localtime()</code>.</p>

<p>If your perl does not support times larger than <code>2^31</code> seconds then this module is likely to fail at processing dates beyond the year 2038. There are moves afoot to fix that in perl. Alternatively use 64 bit perl. Or if none of those are options, use the <a href="DateTime.html">DateTime</a> module which has support for years well into the future and past.</p>

<p>Also, the internal representation of Time::Piece-&gt;strftime deviates from the standard POSIX implementation in that is uses the epoch (instead of separate year, month, day parts). This change was added in version 1.30. If you must have a more traditional strftime (which will normally never calculate day light saving times correctly), you can pass the date parts from Time::Piece into the strftime function provided by the POSIX module (see strftime in <a href="POSIX.html">POSIX</a> ).</p>

<h1 id="AUTHOR"><a class="permalink" href="./Time::Piece.html#AUTHOR">#</a>AUTHOR</h1>

<p>Matt Sergeant, matt@sergeant.org Jarkko Hietaniemi, jhi@iki.fi (while creating Time::Piece for core perl)</p>

<h1 id="COPYRIGHT-AND-LICENSE"><a class="permalink" href="./Time::Piece.html#COPYRIGHT-AND-LICENSE">#</a><a id="COPYRIGHT"></a>COPYRIGHT AND LICENSE</h1>

<p>Copyright 2001, Larry Wall.</p>

<p>This module is free software, you may distribute it under the same terms as Perl.</p>

<h1 id="SEE-ALSO"><a class="permalink" href="./Time::Piece.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<p>The excellent Calendar FAQ at <a href="http://www.tondering.dk/claus/calendar.html">http://www.tondering.dk/claus/calendar.html</a></p>

<h1 id="BUGS"><a class="permalink" href="./Time::Piece.html#BUGS">#</a>BUGS</h1>

<p>The test harness leaves much to be desired. Patches welcome.</p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
